package ctgu.junitTest;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;


import ctgu.java.PreminumCaculator;

class PreminumCaculatortest {

	private final PreminumCaculator preminumCaculator = new PreminumCaculator();

	  // 无效输入测试用例
	  @ParameterizedTest(name = "num1={0}, num2={1},num3={2}, num4={3}")
	  @CsvSource({    
	          "-1,M,已婚,1",    
	          "122,F,未婚,8",
	          "44,2,未婚,8",
	          "50,F,wh,8",
	          "30,M,已婚,-2",
	          "19,M,已婚,10"
	  })
	  void InvalidCases(int num1, String num2, String num3, int num4) {
	    Assertions.assertThrows(
	        AssertionError.class,
	        () -> preminumCaculator.rate(num1, num2,num3,num4));
	  }

	  //有效输入测试用例
	  @ParameterizedTest(name = "num1={0}, num2={1},num3={2}, num4={3}, result={4}")
	  @CsvSource({
	          "22,M,已婚,1,0.006f",  
	          "45,F,未婚,7,0.001f", 
	          "65,M,已婚,8,0.001f"
	  })
	  void ValidCases(int num1, String num2, String num3, int num4, float result) {
	    Assertions.assertEquals(result, preminumCaculator.rate(num1, num2,num3,num4));
	  }


}
